public class RectangleR implements java.lang.Cloneable
{
    private final int DIGITS = 4;
    private double x, y, width, height;

    public RectangleR(double x, double y, double width, double height)
    {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public Object clone() throws CloneNotSupportedException
    {
        RectangleR r = (RectangleR) super.clone();
        r.x = this.x;
        r.y = this.y;
        r.width = this.width;
        r.height = this.height;
        return r;
    }

    public double getX()
    {
        return this.x;
    }

    public double getY()
    {
        return this.y;
    }

    public double getWidth()
    {
        return this.width;
    }

    public double getHeight()
    {
        return this.height;
    }

    public void setX(double x)
    {
        this.x = x;
    }

    public void setY(double y)
    {
        this.y = y;
    }

    public void setWidth(double width)
    {
        this.width = width;
    }

    public void setHeight(double height)
    {
        this.height = height;
    }

    public PointR topLeft()
    {
        return new PointR(this.x, this.y);
    }

    public PointR bottomRight()
    {
        return new PointR(this.x + this.width, this.y + this.height);
    }

    public PointR center()
    {
        return new PointR(this.x + this.width / 2.0, this.y + this.height / 2.0);
    }

    public double maxSide()
    {
        return Math.max(this.width, this.height);
    }

    public double minSide()
    {
        return Math.min(this.width, this.height);
    }

    public double diagonal()
    {
        return Utils.distance(this.topLeft(), this.bottomRight());
    }

    public boolean equals(Object o)
    {
        if (o instanceof RectangleR)
        {
            RectangleR r = (RectangleR) o;
            return (this.x == r.x && this.y == r.y)
                    && (this.width == r.width && this.height == r.height);
        }
        return false;
    }

    public int hashCode()
    {
        return super.hashCode();
    }

}
